Public Class DataParameterCollection
    Implements IDataParameterCollection


    Public Sub New()
        _list = New Generic.List(Of DataParameter)
    End Sub
    Private _list As IList(Of DataParameter)
    Private _HashTable As New Generic.Dictionary(Of String, DataParameter)

    Public Sub CopyTo(ByVal array As System.Array, ByVal index As Integer) Implements System.Collections.ICollection.CopyTo
        _list.CopyTo(array, index)
    End Sub

    Public ReadOnly Property Count() As Integer Implements System.Collections.ICollection.Count
        Get
            Return _list.Count
        End Get
    End Property

    Public ReadOnly Property IsSynchronized() As Boolean Implements System.Collections.ICollection.IsSynchronized
        Get
            Return False
        End Get
    End Property

    Public ReadOnly Property SyncRoot() As Object Implements System.Collections.ICollection.SyncRoot
        Get
            Return Nothing
        End Get
    End Property

    Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
        Return _list.GetEnumerator
    End Function

    Public Function Add(ByVal value As Object) As Integer Implements System.Collections.IList.Add
        _list.Add(value)
        _HashTable.Add(CType(value, DataParameter).ParameterName, value)
    End Function

    Public Sub Clear() Implements System.Collections.IList.Clear
        _list.Clear()
    End Sub

    Public Function Contains(ByVal value As Object) As Boolean Implements System.Collections.IList.Contains
        Return _list.Contains(value)
    End Function

    Public Function IndexOf(ByVal value As Object) As Integer Implements System.Collections.IList.IndexOf
        Return _list.IndexOf(value)
    End Function

    Public Sub Insert(ByVal index As Integer, ByVal value As Object) Implements System.Collections.IList.Insert
        _list.Insert(index, value)
    End Sub

    Public ReadOnly Property IsFixedSize() As Boolean Implements System.Collections.IList.IsFixedSize
        Get
            Return False
        End Get
    End Property

    Public ReadOnly Property IsReadOnly() As Boolean Implements System.Collections.IList.IsReadOnly
        Get
            Return _list.IsReadOnly
        End Get
    End Property

    Default Public Overloads Property Item(ByVal index As Integer) As Object Implements System.Collections.IList.Item
        Get
            Return _list.Item(index)
        End Get
        Set(ByVal value As Object)
            _list.Item(index) = value
        End Set
    End Property

    Public Sub Remove(ByVal value As Object) Implements System.Collections.IList.Remove
        _list.Remove(value)
    End Sub

    Public Sub RemoveAt(ByVal index As Integer) Implements System.Collections.IList.RemoveAt
        _list.RemoveAt(index)
    End Sub

    Public Function Contains(ByVal parameterName As String) As Boolean Implements System.Data.IDataParameterCollection.Contains
        Return _HashTable.ContainsKey(parameterName)
    End Function

    Public Function IndexOf(ByVal parameterName As String) As Integer Implements System.Data.IDataParameterCollection.IndexOf
        If Me.Contains(parameterName) = False Then
            Return -1
        Else
            Dim p As DataParameter = _HashTable.Item(parameterName)
            Return _list.IndexOf(p)
        End If
    End Function

    Default Public Overloads Property Item(ByVal parameterName As String) As Object Implements System.Data.IDataParameterCollection.Item
        Get
            Return _HashTable.Item(parameterName)
        End Get
        Set(ByVal value As Object)
            _HashTable.Item(parameterName) = value
        End Set
    End Property

    Public Sub RemoveAt(ByVal parameterName As String) Implements System.Data.IDataParameterCollection.RemoveAt
        Throw New NotImplementedException()
    End Sub
End Class
